<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>设置</el-breadcrumb-item>
      <el-breadcrumb-item>操作日志</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>

      <h3 style="text-align: left;border-bottom:1px solid gainsboro;padding-bottom: 5px">操作记录</h3>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input  placeholder="请输入操作人" clearable v-model="LogEmpname" @clear="searchBanner">
            <el-button slot="append" icon="el-icon-search" @click="searchBanner"></el-button>
          </el-input>
        </el-col>
      </el-row>
    </el-card>



    <el-card style="margin-top: 30px">



      <el-table :data="LogList" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column label="操作时间" prop="logdata"></el-table-column>
        <el-table-column label="添加人" prop="logemployeename"></el-table-column>


        <el-table-column label="操作模块" prop="logModuleName"></el-table-column>
        <el-table-column label="操作内容" prop="logoperation"></el-table-column>





<!--        <el-table-column label="操作" width="250px">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="showBannereditDialog(scope.row)">编辑</el-button>
            <el-button type="danger" size="mini" @click="removeBannerById(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>-->
      </el-table>
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          :page-sizes="[ 10 , 15, 20]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
      ></el-pagination>
    </el-card>



  </div>
</template>
<script>
export default {
  data() {
    return {
      LogEmpname: "",
      pageNum: 1,
      pageSize: 10,
      total: 14,
      LogList: [],



    };
  },
  methods: {

    //删除Banner
    removeBannerById(id) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url ="banner/del/"+id;
        this.$axios.delete(url).then(res => {
          if (res.data.code == 200) {
            this.$message({
              type: "success",
              message: res.data.msg,
              duration: 1000
            })
            this.reloadData();
          } else {
            this.$message({
              type: "error",
              message: res.data.msg,
              duration: 1000
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },







    //根据名字查所有Banner
    getBannerList() {
      let url = "Log/loglist";
      this.$axios.get(url, {
        params: {
          name: this.LogEmpname,
          now: this.pageNum,
          size: this.pageSize
        }
      }).then(res => {
        if (res.data.code == 200) {
          this.LogList = res.data.data.list;
          this.pageNum = res.data.data.pageNum;
          this.pageSize = res.data.data.pageSize;
          this.total = res.data.data.total;
        } else {
          this.$message({
            type: "error",
            message: res.data.msg,
            duration: 1000
          })
        }
      });

    },
    searchBanner() {
      this.pageNum = 1;
      this.getBannerList();
    },
    handleSizeChange(newSize) {
      this.pageSize = newSize;
      this.getBannerList();
    },
    handleCurrentChange(newPage) {
      this.pageNum = newPage;
      this.getBannerList();
    },
    //把用户对象中包含的BannerList其中的Bannername转换为逗号分隔的字符串
    getBannerNames(arr) {
      if (!arr) return;
      let BannerNameArr = new Array();
      for (let i = 0; i < arr.length; i++) {
        BannerNameArr.push(arr[i].name);
      }
      return BannerNameArr.join(",");
    },

    reloadData() {
      this.searchBanner();

    }
  },
  created() {
    this.reloadData();

  }
};
</script>
<style lang="less" scoped>

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.avata {
  width: 178px;
  height: 178px;
  display: block;
}
</style>